import axios from 'axios'
import { message } from 'antd'
const request = axios.create({
	timeoutErrorMessage: '超时',
	timeout: 10000
})


request.interceptors.request.use((config) => {
	return config
}, error => {
	return Promise.reject(error)
})


request.interceptors.response.use((response) => {
	return response
}, error => {
	const { status } = error.response
	if (status >= 400 && status < 500) {
		message.error('客户端错误！！！')
	} else if (status >= 500) {
		message.error('服务器错误！！！')
	}
	return Promise.reject(error)
})


export default request